package gwtmodule1.client.gui.salesdept;

import gwtmodule1.client.gui.utils.DekoTable;
import gwtmodule1.client.gui.utils.FrameClient;
import gwtmodule1.client.gui.utils.HSpacer;
import gwtmodule1.client.gui.utils.Title;

import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

public class PageAdminGiftcards extends VerticalPanel implements FrameClient {

	private class GiftCardTable extends DekoTable {

		public GiftCardTable() {
			super();
			TextBox val = new TextBox();
			val.setWidth("64px");
			TextBox amo = new TextBox();
			amo.setWidth("64px");
			
			addTitle("Value");
			addTitle("Available");
			addTitle("");
			addTitle("Total");
			
			AddRow r1 = addRow();
			r1.add("").setColspan(3);
			r1.add("1234.56 USD").bold();
			
			AddRow r2 = addRow();
			r2.add(val);
			r2.add(amo);
			r2.add(new Button("add"));
			r2.add("");
		}

		public void addItem(float value, int avail) {
			TextBox av = new TextBox();
			av.setText(avail+ "");
			av.setWidth("64px");
			av.setTextAlignment(TextBox.ALIGN_RIGHT);
			
			AddRow r = addRow(2);
			r.add(value + " USD");
			r.add(av);
			r.add(new Button("delete"));
			r.add((avail * value) + " USD");
		}

	}

	private Widget createTable() {
		GiftCardTable table = new GiftCardTable();
		table.addItem(10, 200);
		table.addItem(50, 50);
		table.addItem(150, 10);
		return table;
	}

	public PageAdminGiftcards() {
		super();
		add(new Title("Available Gift Cards"));
		setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
		add(new Button("Save Changes"));
		setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
		add(new HSpacer("4px"));
		add(createTable());
	}

	public void onShow(Object param) {
	}

}
